package com.swipemaster.achievements;

import java.io.Serializable;
import java.util.ArrayList;

import com.swipemaster.Constants;

/**
 * Collection containing all information about levels.
 */
public class LevelsInfo implements Serializable
{
	private static final long serialVersionUID = 1L;
	private ArrayList<SingleLevelInfo> levelInfo = new ArrayList<SingleLevelInfo>();

	/**
	 * Constructs all levels with default values. Unlocks first level.
	 */
	public LevelsInfo()
	{
		for (int i = 0; i < Constants.LEVELS; i++)
		{
			levelInfo.add(new SingleLevelInfo());
		}
		unlockFirstLevel();
	}

	/**
	 * Unlocks first level, so that user can start to play.
	 */
	private void unlockFirstLevel()
	{
		SingleLevelInfo singleLevelInfo = getInfo(0);
		singleLevelInfo.setLocked(false);
	}

	/**
	 * Get information about level with given index, 0-based.
	 * 
	 * @param index Index of level, 0-based.
	 * @return Object of SingleLevelInfo.
	 */
	public SingleLevelInfo getInfo(int index)
	{
		return levelInfo.get(index);
	}
}
